package com.jumi.microservice.transfers.common;

import com.jumi.microservice.dto.PayTransferQueryRequest;
import com.jumi.microservice.dto.PayTransferRequest;

import javax.annotation.PostConstruct;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Scw
 * @Date 2019-09-29 09:36
 */
public abstract class BaseTransfer {
    public static Map<Integer, BaseTransfer> transferMap = new ConcurrentHashMap<>();

    @PostConstruct
    public void init() {
        transferMap.put(this.getType(), this);
    }

    public abstract Context createContext(PayTransferRequest request);

    public abstract Map<String, String> doProcess(Context context);

    public abstract Integer getType();

    public Map<String, String> process(PayTransferRequest request) {
        return doProcess(createContext(request));
    }

    public abstract String transferQuery(PayTransferQueryRequest payTransferQueryRequest);
}
